import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router)

export default new Router({
    hashbang: true,
    routes: [
        //入口页面
        {
            path: '/',
            name: 'index',
            redirect: '/homeMenu/home',
            component: resolve => require(['@/components/home/homeMenu.vue'], resolve)
        },
        {
            path: '/login',
            name: 'login',
            meta: {
                title: 'Login - 登录'
            },
            component: resolve => require(['@/components/login.vue'], resolve)
        },
        //首页
        {
            path: '/homeMenu',
            name: 'homeMenu',
            redirect: '/homeMenu/home',
            component: resolve => require(['@/components/home/homeMenu.vue'], resolve),
            children: [{
                path: 'home',
                name: 'home',
                component: resolve => require(['@/components/home/home.vue'], resolve)
            }]
        },
        //订单
        {
            path: '/orderMenu',
            name: 'orderMenu',
            redirect: '/orderMenu/orderList',
            component: resolve => require(['@/components/order/orderMenu.vue'], resolve),
            children: [{
                path: 'orderList',
                name: 'orderList',
                component: resolve => require(['@/components/order/orderList.vue'], resolve)
            }]
        },
        //商品
        {
            path: '/shopMenu',
            name: 'shopMenu',
            redirect: '/shopMenu/shopList',
            component: resolve => require(['@/components/shop/shopMenu.vue'], resolve),
            children: [{
                    path: 'shopList',
                    name: 'shopList',
                    component: resolve => require(['@/components/shop/shopList.vue'], resolve)
                },
                {
                    path: 'shopType',
                    name: 'shopType',
                    component: resolve => require(['@/components/shop/shopType.vue'], resolve)
                },
                {
                    path: 'shopDetail',
                    name: 'shopAdd',
                    component: resolve => require(['@/components/shop/shopDetail.vue'], resolve)
                },
                {
                    path: 'shopList/:id',
                    name: 'shopDetail',
                    component: resolve => require(['@/components/shop/shopDetail.vue'], resolve)
                },
            ]
        },
        // 门店
        {
            path: '/storeMenu',
            name: 'storeMenu',
            redirect: '/storeMenu/fullCut',
            component: resolve => require(['@/components/store/storeMenu.vue'], resolve),
            children: [{
                    path: 'fullCut',
                    name: 'fullCut',
                    component: resolve => require(['@/components/store/fullCut.vue'], resolve)
                },
                {
                    path: 'newCut',
                    name: 'newCut',
                    component: resolve => require(['@/components/store/newCut.vue'], resolve)
                }
            ]
        },
        //用户
        {
            path: '/userMenu',
            name: 'userMenu',
            redirect: '/userMenu/userList',
            component: resolve => require(['@/components/user/userMenu.vue'], resolve),
            children: [{
                    path: 'userList',
                    name: 'userList',
                    component: resolve => require(['@/components/user/userList.vue'], resolve)
                }, {
                    path: 'userList/:id',
                    name: 'userDetail',
                    component: resolve => require(['@/components/user/userDetail.vue'], resolve)
                },
                {
                    path: 'userDetail/:id',
                    name: 'userPayDetail',
                    component: resolve => require(['@/components/user/userPayDetail.vue'], resolve)
                }
            ]
        },
        //统计
        {
            path: '/accountMenu',
            name: 'accountMenu',
            redirect: '/accountMenu/shopAccount',
            component: resolve => require(['@/components/account/accountMenu.vue'], resolve),
            children: [{
                path: 'shopAccount',
                name: 'shopAccount',
                component: resolve => require(['@/components/account/shopAccount.vue'], resolve)
            }]
        },
        //设置
        {
            path: '/setMenu',
            name: 'setMenu',
            redirect: '/setMenu/shopSet',
            component: resolve => require(['@/components/set/setMenu.vue'], resolve),
            children: [{
                path: 'shopSet',
                name: 'shopSet',
                component: resolve => require(['@/components/set/shopSet.vue'], resolve)
            }, {
                path: 'paySet',
                name: 'paySet',
                component: resolve => require(['@/components/set/paySet.vue'], resolve)
            }, {
                path: 'sendSet',
                name: 'sendSet',
                component: resolve => require(['@/components/set/sendSet.vue'], resolve)
            }, {
                path: 'noticeSet',
                name: 'noticeSet',
                component: resolve => require(['@/components/set/noticeSet.vue'], resolve)
            }]
        },
        //错误页面404
        {
            path: '/*',
            name: 'error-404',
            meta: {
                title: '404-页面不存在'
            },
            component: resolve => require(['@/components/error/404.vue'], resolve)
        },
        //服务器端错误500
        {
            path: '/500',
            meta: {
                title: '500-服务端错误'
            },
            name: 'error-500',
            component: resolve => require(['@/components/error/500.vue'], resolve)
        }
    ]
})